﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MusicStoreMVC.Models;

namespace MusicStoreMVC.Controllers
{
    public class StoreController : Controller
    {
        //
        // GET: /Store/

       DB_MUSIC_STOREContext storeDB = new DB_MUSIC_STOREContext();

        public ActionResult Index()
        {
            //var oGenreCollection = new List<Genre>
            //{
            //  new Genre { Name = "Disco"}  ,
            //  new Genre {Name = "Jazz"},
            //  new Genre {Name = "Rock"}
            //};

            var oGenreCollection = storeDB.Genres.ToList();

            return View(oGenreCollection);
        }

        // GET: /Store/Browse
        public ActionResult Browse(string genre)
        {
            //var oGenre = new Genre { Name = genre };
            var oGenre = storeDB.Genres.Include("Albums").Single(g => g.Name == genre);
            return View(oGenre);
        }

        // GET: /Store/Details/5
        public ActionResult Details(int id)
        {
            var oAlbum = new Album { Title = "Album " + id  };
            return View(oAlbum);
        }

        public string Store(int id)
        {
            string message = HttpUtility.HtmlEncode("probando Store " + id);
            return message;
        }
    }
}
